import Vue from 'vue'
import BaiduMap from 'vue-baidu-map-v3'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/baseScss.scss' // css
import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'

import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;


import $ from 'jquery'
import animate from 'animate.css'
Vue.use(animate);
// import 'default-passive-events'


import './assets/icons' // icon
import './permission' // permission control
import { getDicts} from "@/api/system/dict/data";

import { getConfigKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree,downloadNotD,trimSpace,strToCamelCase,
  dictFormat,groupArr,selectDictLabelDefault,selectItemByList,verifyNumDefault,selectDictLabelAndDefault} from "@/utils/baseUtil";
import Pagination from "@/components/Pagination";
import { getRandomByRange,getRandomArrByRange} from "@/utils/numberUtil";
//自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"

import './utils/dialog'

// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.downloadNotD = downloadNotD;
Vue.prototype.handleTree = handleTree;
Vue.prototype.trimSpace =trimSpace;
Vue.prototype.dictFormat =dictFormat;
Vue.prototype.selectDictLabelDefault = selectDictLabelDefault;
Vue.prototype.getRandomByRange = getRandomByRange;
Vue.prototype.getRandomArrByRange = getRandomArrByRange;
Vue.prototype.groupArr =groupArr;
Vue.prototype.selectItemByList =selectItemByList;
Vue.prototype.verifyNumDefault =verifyNumDefault;
Vue.prototype.selectDictLabelAndDefault =selectDictLabelAndDefault;
Vue.prototype.strToCamelCase = function (str,isTrue){
  if(!str){ return "" }
  let arr=str.split("_");
  let num=1;
  if(isTrue===true){
    num=0;
  }
  for(let i=num;i<arr.length;i++){
    arr[i]=arr[i].charAt(0).toUpperCase()+arr[i].substring(1);
  }
  return arr.join("");
};
Vue.prototype.genInfluxSeries = function  (series){
  let arr=[];
  if(series.values){
    series.values.forEach(v => {
      let item = {};
      for (let i = 0; i < v.length; i++) {
        item[series["columns"][i]] = v[i]
      }
      arr.push(item);
    })
  }
  return arr;
};

import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel);

Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
};

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error" });
};

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
};



// 全局组件挂载
Vue.component('Pagination', Pagination);
Vue.component('RightToolbar', RightToolbar);
Vue.use(permission);


import VueJsonp from 'vue-jsonp'
Vue.use(VueJsonp);
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
});

Vue.config.productionTip = false;

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
});
